# ---------- ---------- ---------- ---------- ---------- ----------
#
# django_sso
#
#    1) config, vars, and target
#    2) functions
#    3) phonies
#
# ---------- ---------- ---------- ---------- ---------- ----------

NAME=django_sso

target: help


# ---------- ---------- ---------- ---------- ---------- ----------
# functions
# ---------- ---------- ---------- ---------- ---------- ----------

define fix-python
	@isort . || echo "isort returned nonzero"
	@black . || echo "black returned nonzero"
endef


define lint
	@ruff check . || echo "ruff returned nonzero"
endef


define lint-types
	@mypy . || echo "mypy returned nonzero"
endef


define find-cve
	@pip-audit || echo "pip-audit returned nonzero"
endef


# ---------- ---------- ---------- ---------- ---------- ----------
# phonies
# ---------- ---------- ---------- ---------- ---------- ----------

.PHONY: help
help:
	@echo "Usage: make [PHONY]"
	@sed -n -e "/sed/! s/\.PHONY: //p" Makefile
	@echo ""


.PHONY: clean
clean:
	@py3clean ./src/ ./tests/ || echo "pyclean not installed"
	@rm -rf var/ .mypy_cache/


.PHONY: fix-python
fix-python:
	@$(call fix-python)


.PHONY: fix-all
fix-all: fix-python


.PHONY: lint
lint:
	@$(call lint)


.PHONY: lint-types
lint-types:
	@$(call lint-types)


.PHONY: find-cve
find-cve:
	@$(call find-cve)


.PHONY: dev
dev: fix-all lint lint-types find-cve test


.PHONY: test
test:
	@coverage run --source='.' -m unittest discover -s tests.django_sso_tests -t .
	@coverage report -m
